package com.qiezi.project.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.qiezi.R;
import com.qiezi.util.Util;

public class BlockView extends RelativeLayout {
    public BlockView(Context context) {
        super(context);
    }

    public BlockView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context,attrs,0);
    }

    private String title;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
        if (tvTitle != null) tvTitle.setText(title);
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
        if (tvValue != null) tvValue.setText(value);
    }

    private String value;

    private TextView tvTitle,tvValue;

    private void init(Context context,AttributeSet attrs,int p){
        LayoutInflater.from(context).inflate(R.layout.view_block, this);
        if (attrs != null){
            TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.BlockView, p, 0);
            title = typedArray.getString(R.styleable.BlockView_bv_title);
            value = typedArray.getString(R.styleable.BlockView_bv_value);
            typedArray.recycle();
        }

        tvTitle = findViewById(R.id.tv_b_title);
        tvValue = findViewById(R.id.tv_b_value);

        tvTitle.setText(title);
        tvValue.setText(value);
    }
}
